An important object-oriented technique is that of deriving new classes from existing classes. A derived class (descendant, child or subclass) is one which INHERITS the instance variable and method declarations of the base class (ancestor, parent or superclass), and adds instance variables and methods of its own. In C++, methods are inherited only if the original declaration uses the 'virtual' keyword. A derived class may also provide new definitions for the methods declared in the base class, in which case the new definition is said to "override" the original. The syntax to derive the Student class from the Person class is:
struct Student:Person
{
int student_num; /* additional instance variable */
void set(void); /* override original set() method */
void print(void); /* override original print() method */